<?php if (! defined ( 'BASEPATH' ))exit ( 'No direct script access allowed' );
include_once 'smarty/Smarty.class.php';
class Base extends CI_Controller {
	private $smarty;
	public $ftp_name;
	function __construct() {
		parent::__construct ();
		$this->smarty = new Smarty ();
		$this->smarty->template_dir = APPPATH . "templates";
		$this->smarty->compile_dir = APPPATH . "templates_c";
		$this->smarty->caching = 0;
		$this->smarty->error_reporting = true;  //屏蔽模版的报错  、如果不要屏蔽请注释该条
		$this->smarty->debugging = false;
		$this->smarty->left_delimiter = "{";
		$this->smarty->right_delimiter = "}";
		//启动session
		session_start();
		$_SESSION['i'] = "sdf";
	}
	/**
	 * 输出模版页
	 * @param string $path
	 * 	  默认 对应相应模版目录下的类名下的方法名模版
	 * 	       也可自行制定相应的模版
	 */
	function display($path="") {
		$class = $this->router->fetch_class ();
		$method = $this->router->fetch_method ();
		if (! $path) {
			$path = $class . "/" . $method;
		} else {
			if (! strstr ( $path, "/" )){ 
				$path = $class."/".$path;
			}
		}
		$this->smarty->display ( $path.".html" );
	}
	/**
	 * 给模版传递参数
	 * @param string $name
	 * @param string $value
	 */
	function assign($name,$value){
		$this->smarty->assign($name,$value);
	}
	
	/**
	 * 以json的形式返回ajax的处理结果通用函数
	 * @param int $status   返回状态标记符 
	 * @param string  $info  返回状态结果
	 * @param array $data  返回数据
	 */
	function ajaxReturn($status=1,$info="success",$data=""){
		$d['status'] = $status;
		$d['info'] = $info;
		$d['data'] = $data;
		return json_encode($d);
	}
}
